-
-
Notifications
You must be signed in to change notification settings - Fork 414
Msvc nan inf #355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Msvc nan inf #355
Conversation
This is not a search and replace of __MING32__ with _WIN32. There are places where __MINGW32__ is still used and all changes are tested with MSVC 2019 compiler. Although, this commit alone will not work on MSVC because there are plenty of other things to be done which are seperated into multiple PR. PR OSGeo#289 is the one that "works" on MSVC and unix as well. But that contains too many changes which shouldn't in a single PR. Even though this PR alone won't compile GRASS GIS on MSVC, it sure will not break existing compilers which I think is very important. Complete support for MSVC will be ready after 2/3 PRs OSGeo#289
static int initialized is not working for MSVC and must export this with __declspec so that it appears in a DLL correctly. This change has been tested on Ubuntu and MSVC 2019 and is working as expected.
Below is a code from filldepr.cpp which throws error on msvc compiler
function has G_fatal_error() so it is 'normal' to have no return type.
But MSVC complains that function's return type is elevation_type*
and does not return anything.
elevation_type*
ext_fill_depression(AMI_STREAM<boundaryType> *boundaryStr,
cclabel_type maxWatersheds) {
G_fatal_error(_("Fill_depressions do not fit in memory. Not implemented yet"));
}
The MSVC compiler only supports C90, it does not support C99 and variable length arrays are a feature of C99.
|
Was this addressed somewhere? I don't know. Please, close if you know the PR where this was fixed. Otherwise, I suggest closing this when CMake build works on Windows. |
echoix
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // GCC 5.4.0 says 0./0. is -nan | ||
| // Clang 3.8.0 says 0./0. is nan | ||
| // I stick to -nan in msvc too. But this has to rechecked. | ||
| sscanf("-nan", "%lf", &convergence); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In #2681, the code was changed to use NAN, but there's a note that some of them won't work for MSVC (at that time), but it was not mentioned for the NAN change.
if (G_projection() == PROJECTION_XY)
convergence = NAN;| sn.uid = *skip; | ||
|
|
||
| maxdist = 1.0 / 0.0; | ||
| sscanf("inf", "%lf", &maxdist); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In #2681, the code was changed to use INFINITY, but there's a note that it might not for MSVC (at that time)
| double nan_val; | ||
| sscanf("-nan", "%lf", &nan_val); | ||
| Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = nan_val; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In #2681, the code was changed to use NAN:
Line = Plus->Line[line];
if (Line == NULL) { /* dead */
Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = NAN;
return 0;
}| double nan_val; | ||
| sscanf("-nan", "%lf", &nan_val); | ||
| Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = nan_val; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In #2681, the code was changed to use NAN:
if (Area == NULL) { /* dead */
Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = NAN;
return 0;
}| double nan_val; | ||
| sscanf("-nan", "%lf", &nan_val); | ||
| Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = nan_val; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In #2681, the code was changed to use NAN:
Isle = Plus->Isle[isle];
if (Isle == NULL) { /* dead */
Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = NAN;
return 0;
}| double nan_val; | ||
| sscanf("-nan", "%lf", &nan_val); | ||
| min_x = max_x = min_y = max_y = min_z = max_z = nan_val; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In #2681, the code was changed to use NAN:
/* init to nan in case no points are found */
min_x = max_x = min_y = max_y = min_z = max_z = NAN;| n = 0; | ||
| sum = sumsq = 0; | ||
| min = 1.0 / 0.0; | ||
| sscanf("inf", "%lf", &min); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In #2681, the code was changed to use INFINITY, but there's a note that it might not for MSVC (at that time)
min = INFINITY;| n = 0; | ||
| sum = sumsq = 0; | ||
| min = 1.0 / 0.0; | ||
| sscanf("inf", "%lf", &min); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In #2681, the code was changed to use INFINITY, but there's a note that it might not for MSVC (at that time)
min = INFINITY;| double nan_val; | ||
| sscanf("-nan", "%lf", &nan_val); | ||
| box->E = box->W = box->N = box->S = box->T = box->B = nan_val; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In #2681, the code was changed to use NAN:
if (Points->n_points == 0) {
box->E = box->W = box->N = box->S = box->T = box->B = NAN;
return 0;
}| } | ||
|
|
||
| distmin = 1. / 0.; /* +inf */ | ||
| sscanf("inf", "%lf", &distmin); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In #2681, the code was changed to use INFINITY, but there's a note that it might not for MSVC (at that time)
distmin = INFINITY;|
Replaced by: #5511 |
To be merged after #354